package xcmg.device.infra.enums;

/**
 * 调拨计划的状态
 */
public enum ReginAllotPlanStatusEnum {
    save(0, "编辑"),
    submit(1, "已提交"),
    part(2, "部分调拨"),
    endBill(3, "结单"),
    done(4, "已完成");

    private String desc;
    private int code;

    ReginAllotPlanStatusEnum(int code, String desc) {
        this.desc = desc;
        this.code = code;
    }

    public static boolean canNanuFinishStatus(int code) {
        if (submit.getCode() == code || part.getCode() == code) {
            return true;
        }
        return false;
    }

    public static boolean canCreateRegionAllot(int code) {
        return submit.getCode() == code || part.getCode() == code;
    }

    /**
     * 是否结单
     *
     * @param code
     * @return
     */
    public static boolean isEnd(int code) {
        return endBill.getCode() == code;
    }

    public static String getDescByCode(Integer planStatus) {
        if(null==planStatus){
            return "";
        }
        for(ReginAllotPlanStatusEnum e:ReginAllotPlanStatusEnum.values()){
            if(e.getCode()==planStatus.intValue()){
                return e.getDesc();
            }
        }
        return "";
    }

    public String getDesc() {
        return desc;
    }

    public int getCode() {
        return code;
    }

}
